package com.ymatou.app.testcase;

import org.json.JSONArray;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.app.parameter.ProductListBean;
import com.ymatou.app.parameter.SellerCouponListBean;
import com.ymatou.app.service.ProductListCall;
import com.ymatou.app.service.SellerCouponListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.BuyerCallService;
import com.ymttest.business.service.SellerCallService;

public class Ts_SellerCouponList {
	
	private static SellerCouponListBean sellerCouponListBean;
	private static SellerCouponListCall sellerCouponListCall;
	private static BuyerCallService buyerCallService;
	private int activityId = 0;
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商品列表接口");
		buyerCallService = new BuyerCallService("ukseller", "aabbcc");
	}

	@Before
	public void caseUp() {
		sellerCouponListCall = new SellerCouponListCall();
		sellerCouponListBean = new SellerCouponListBean();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(sellerCouponListCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ProductList_001() {
		Logger.start(true,"验证商家优惠券数量");
		try {
			Logger.comment("验证开始");
			int sellerid = buyerCallService.getLiveInfo().getInt("id");
			
			sellerCouponListBean.setSellerid(sellerid);
			
			sellerCouponListCall.setData(sellerCouponListBean);
			sellerCouponListCall.callService();			
			Logger.comment("activityCall send:" + sellerCouponListCall.getEntityString());
			Logger.comment("activityCall response:" + sellerCouponListCall.getReturnData());
			
			Logger.verifyEquals(3, sellerCouponListCall.getCoupons().length(), "验证优惠券数量");
			
			/*activityId = sellerCallService.getActivityInProgress();
			sellerCallService.closeActivity(activityId);*/
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
